<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">原始内容</div>
  <script>
    const data = {
      msg: 'hello',
      content: 'message',
      arr: [1,2,3],
      obj: {
        name: 'cc',
        age: 18
      }
    }
    // 兼容情况
    const vm = new Proxy(data, {
      get(target, key){
        return target[key]
      },
      set(target, key, newValue){
        //数据更新
        target[key] = newValue
        //视图更新
        document.querySelector('#app').textContent = target[key]
      }
    })
  </script>
</body>
</html>